<?php $this->_extends('../_layouts/default_layout');?>
<?php $this->_block('contents');?>
<link type="text/css" href="<?=Q::ini('custom_system/base_url')?>css/prettyphoto.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Q::ini('custom_system/base_url')?>js/jq.prettyphoto.js"></script>
<script type="text/javascript">
$(function(){
	$("a[rel^='pretty_photo']").prettyPhoto({theme:'facebook'});
	$(".datepicker").datepicker({dateFormat: 'yy-mm-dd', changeMonth: true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<?php include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
	<tr>
		<th>创建日期</th>
		<td>
			<input type="text" name="begin_create_time" class="datepicker" value="<?=isset($_GET['begin_create_time']) ? $_GET['begin_create_time'] : ''?>"/> to 
			<input type="text" name="end_create_time" class="datepicker" value="<?=isset($_GET['end_create_time']) ? $_GET['end_create_time'] : ''?>"/>
		</td>
	</tr>
	<tr>
		<th>采购审核日期</th>
		<td>
			<input type="text" name="begin_purchase_audit_time" class="datepicker" value="<?=isset($_GET['begin_purchase_audit_time']) ? $_GET['begin_purchase_audit_time'] : ''?>"/> to 
			<input type="text" name="end_purchase_audit_time" class="datepicker" value="<?=isset($_GET['end_purchase_audit_time']) ? $_GET['end_purchase_audit_time'] : ''?>"/>
		</td>
	</tr>
	<tr>
		<th>财务审核日期</th>
		<td>
			<input type="text" name="begin_finance_audit_time" class="datepicker" value="<?=isset($_GET['begin_finance_audit_time']) ? $_GET['begin_finance_audit_time'] : ''?>"/> to 
			<input type="text" name="end_finance_audit_time" class="datepicker" value="<?=isset($_GET['end_finance_audit_time']) ? $_GET['end_finance_audit_time'] : ''?>"/>
		</td>
	</tr>
	<tr>
		<th>产品编号</th>
		<td><input type="text" name="product_basic_number" value="<?=isset($_GET['product_basic_number']) ? $_GET['product_basic_number'] : ''?>" /> 输入产品编号后六位例如：000001</td>
	</tr>
	<tr>
		<th>创建人员</th>
		<td>
			<select name="create_user_id">
				<option value="">请选择..</option>
				<?foreach ($user as $u):?>
				<option value="<?=$u['id']?>" <?if (isset($_GET['create_user_id']) && $_GET['create_user_id'] == $u['id']) echo "selected='selected'"?>><?=$u['name']?></option>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>采购审核</th>
		<td>
			<?foreach (Q::ini('custom_flag/purchase_loss_purchase_audit') as $fa):?>
				<label><input type="checkbox" name="purchase_audit[<?=$fa['value']?>]" value="<?=$fa['value']?>" <?if (isset($_GET['purchase_audit']) && array_key_exists($fa['value'], $_GET['purchase_audit'])) echo "checked='checked'";?>/><?=$fa['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th>财务审核</th>
		<td>
			<?foreach (Q::ini('custom_flag/purchase_loss_finance_audit') as $fa):?>
				<label><input type="checkbox" name="finance_audit[<?=$fa['value']?>]" value="<?=$fa['value']?>" <?if (isset($_GET['finance_audit']) && array_key_exists($fa['value'], $_GET['finance_audit'])) echo "checked='checked'";?>/><?=$fa['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th></th>
		<td><input type="submit" class="button" value="查询" /></td>
	</tr>
</table>
</form>
</fieldset>
<table class="list_table" width="100%">
	<tr>
		<th width="30">ID</th>
		<th width="250">产品</th>
		<th width="50">单价</th>
		<th width="40">数量</th>
		<th width="100">创建时间</th>
		<th width="70">创建人</th>
		<th width="100">采购审核时间</th>
		<th width="70">采购审核</th>
		<th width="100">财务审核时间</th>
		<th width="70">财务审核</th>
		<th width="">原因</th>
		<th width="110">操作</th>
	</tr>
	<?foreach ($purchase_loss as $pl):?>
	<tr>
		<td><?=$pl['id']?></td>
		<td style="text-align:left">
			<?if ($pl['pic_url']):?>
			<?$pretty_photo_number = 0;?>
			<?foreach ($pl['pic_url'] as $pp):?>
			<a rel="pretty_photo[<?=$pl['id']?>]" href="<?=$pp?>"><?if(!$pretty_photo_number):?><span class="img_icon"></span><?endif;?></a>
			<?$pretty_photo_number = 1;?>
			<?endforeach;?>
			<?endif;?>
			<?="（" . $pl['number'] . "）" . $pl['name']?>
		</td>
		<td><?=sprintf('%.2f', $pl['price'])?></td>
		<td><?=$pl['quantity']?></td>
		<td><?=isset($pl['create_time']) ? date('Y-m-d', strtotime($pl['create_time'])) : ''?></td>
		<td><?=$pl['create_user_name']?></td>
		<td><?=isset($pl['purchase_audit_time']) ? date('Y-m-d', strtotime($pl['purchase_audit_time'])) : ''?></td>
		<td><?=Helper_BSS_Normal::getIniOne('purchase_loss_purchase_audit', 'value', $pl['purchase_audit'], 'name')?></td>
		<td><?=isset($pl['finance_audit_time']) ? date('Y-m-d', strtotime($pl['finance_audit_time'])) : ''?></td>
		<td><?=Helper_BSS_Normal::getIniOne('purchase_loss_finance_audit', 'value', $pl['finance_audit'], 'name')?></td>
		<td><?=$pl['reason']?></td>
		<td>
			<?if ($pl['purchase_audit'] == Q::ini('custom_flag/purchase_loss_purchase_audit/audited/value')):?>
			<font color="#aaaaaa">修改</font>
			<font color="#aaaaaa">删除</font>
			<font color="#aaaaaa">审核</font>
			<?else:?>
			<a class="edit" href="<?=url('Purchase::Loss/LossEdit', array('purchase_loss_id' => $pl['id']))?>">修改</a>
			<a class="del" href="<?=url('Purchase::Loss/LossDelete', array('purchase_loss_id' => $pl['id']))?>" onclick="if(!confirm('确定删除？')) return false;">删除</a>
			<a class="audit" href="<?=url('Purchase::Loss/PurchaseAudit', array('purchase_loss_id' => $pl['id']))?>">审核</a>
			<?endif;?>
		</td>
	</tr>
	<?endforeach;?>
</table>
<?=$page;?>
<?php $this->_endblock();?>